package cn.ht.jywrwater.module.ht.dal.mysql.customers;

import java.util.*;

import cn.ht.jywrwater.framework.common.pojo.PageResult;
import cn.ht.jywrwater.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ht.jywrwater.framework.mybatis.core.mapper.BaseMapperX;
import cn.ht.jywrwater.module.ht.dal.dataobject.customers.CustomersDO;
import org.apache.ibatis.annotations.Mapper;
import cn.ht.jywrwater.module.ht.controller.admin.customers.vo.*;

/**
 * 用户 Mapper
 *
 * @author hzx
 */
@Mapper
public interface CustomersMapper extends BaseMapperX<CustomersDO> {

    default PageResult<CustomersDO> selectPage(CustomersPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CustomersDO>()
                .eqIfPresent(CustomersDO::getCustomerCode, reqVO.getCustomerCode())
                .likeIfPresent(CustomersDO::getCustomerName, reqVO.getCustomerName())
                .eqIfPresent(CustomersDO::getCustomerTel, reqVO.getCustomerTel())
                .eqIfPresent(CustomersDO::getPriceCode, reqVO.getPriceCode())
                .orderByDesc(CustomersDO::getId));
    }

    default List<CustomersDO> selectList(CustomersExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<CustomersDO>()
                .eqIfPresent(CustomersDO::getCustomerCode, reqVO.getCustomerCode())
                .likeIfPresent(CustomersDO::getCustomerName, reqVO.getCustomerName())
                .eqIfPresent(CustomersDO::getCustomerTel, reqVO.getCustomerTel())
                .eqIfPresent(CustomersDO::getPriceCode, reqVO.getPriceCode())
                .orderByDesc(CustomersDO::getId));
    }

}
